﻿using AlibabaCloud.OpenApiClient.Models;
using Easy.Cloud.Communication.Sms.Ali.Options;
using Easy.Cloud.Communication.Sms.Core;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Text;

namespace Easy.Cloud.Communication.Sms.Ali
{
    public static class SmsOptionsExtensions
    {
        public static SmsOptions UseAli(this SmsOptions options, IConfiguration configuration, string configName = SmsConst.DefaultOptionSelectName + "AliOptions"
            )
        {
            var option = configuration.GetSection($"{configName}").Get<AliOptions>();

            if (option is null)
                throw new ArgumentNullException(nameof(option));

            options.RegisterExtension(new AliSmsOptionsExtension(option));

            return options;
        }
    }
}
